// src/store/filterSlice.js
import { createSlice } from '@reduxjs/toolkit';

const initialState = {
    commodityName: '',
    popularity: '',
    categoryId: '',
    inventoryStatus: '',
};

const filterSlice = createSlice({
    name: 'filters',
    initialState,
    reducers: {
        setCommodityName: (state, action) => {
            state.commodityName = action.payload;
        },
        setPopularity: (state, action) => {
            state.popularity = action.payload;
        },
        setCategoryId: (state, action) => {
            state.categoryId = action.payload;
        },
        setInventoryStatus: (state, action) => {
            state.inventoryStatus = action.payload;
        },
        resetFilters: () => initialState,
    },
});

export const { setCommodityName, setPopularity, setCategoryId, setInventoryStatus, resetFilters } = filterSlice.actions;
export default filterSlice.reducer;
